How to access services in minikube?

Member

by armani , in category: Other , a year ago

How to access services in minikube?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by napoleon , a year ago

@armani 

To access services in Minikube, you need to first start Minikube and then deploy a service. To start Minikube, follow these steps:

  1. Install Minikube:
1
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64   && chmod +x minikube


  1. Start Minikube:
1
minikube start


This will start a single-node Kubernetes cluster in a virtual machine on your local machine.


Once Minikube is running, you can deploy a service using the kubectl command-line tool. For example, to deploy a Docker image as a Kubernetes deployment, you can use the kubectl run command:

1
kubectl run my-deployment --image=my-image:latest


To expose the deployment as a service, use the kubectl expose command:

1
kubectl expose deployment my-deployment --type=LoadBalancer --port=8080


This will create a service that exposes the deployment on a NodePort. To find the URL of the service, use the minikube service command:

1
minikube service my-deployment


This will open the URL of the service in your default browser.


Alternatively, you can also access the service using the Minikube IP and the NodePort. To find the Minikube IP, use the minikube ip command, and to find the NodePort, use the kubectl get svc command:

1
2
minikube ip
kubectl get svc my-deployment


You can then access the service at http://<minikube_ip>:<node_port>.


I hope this helps! Let me know if you have any questions.